// pages/recruitDynamics/highDemand/highDemand.js
import { throttle } from "../../../utils/throttle";
Page({
  /**
   * 页面的初始数据
   */
  data: {
    hidden: true, //是否隐藏滚动页面时的下拉栏
    timeType: "本月",
    city: "广州市",
    county: "天河区",
    jobList: [
      {
        rank: 1,
        jobName: "数学老师",
        jobTag: "小学",
        count: 39,
        follow: 3890,
      },
      {
        rank: 2,
        jobName: "幼儿园老师",
        jobTag: "幼儿园",
        count: 139,
        follow: 1890,
      },
      {
        rank: 3,
        jobName: "信息技术老师",
        jobTag: "初中",
        count: 39,
        follow: 890,
      },
      {
        rank: 4,
        jobName: "历史老师",
        jobTag: "高中",
        count: 9,
        follow: 90,
      },
      {
        rank: 5,
        jobName: "历史老师",
        jobTag: "高中",
        count: 9,
        follow: 90,
      },
      {
        rank: 6,
        jobName: "历史老师",
        jobTag: "高中",
        count: 9,
        follow: 90,
      },
      {
        rank: 7,
        jobName: "历史老师",
        jobTag: "高中",
        count: 9,
        follow: 90,
      },
      {
        rank: 8,
        jobName: "历史老师",
        jobTag: "高中",
        count: 9,
        follow: 90,
      },
      {
        rank: 9,
        jobName: "历史老师",
        jobTag: "高中",
        count: 9,
        follow: 90,
      },
      {
        rank: 10,
        jobName: "历史老师",
        jobTag: "高中",
        count: 9,
        follow: 90,
      },
    ],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {},

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    const that = this;
    //获取标题底部到页面顶部的距离
    wx.createSelectorQuery()
      .select("#title")
      .boundingClientRect()
      .exec(function (res) {
        that.setData({
          titleBottom: res[0].bottom,
        });
      });
  },
  /**
   * 监听页面滚动
   */ onPageScroll: throttle(function (data) {
    const { scrollTop } = data;
    const { titleBottom } = this.data;
    if (scrollTop > titleBottom) {
      wx.setNavigationBarTitle({ title: "高需求岗位" });
      this.setData({ hidden: false });
    } else {
      wx.setNavigationBarTitle({ title: "招教概况" });
      this.setData({ hidden: true });
    }
  }),

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {},
});
